﻿namespace ExamV5.WAPPage
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmShowNews : Page
    {
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        protected ImageButton ImgButExit;
        private int int_0 = 0;
        protected Label labInputUser;
        protected Label labNewsInfo;
        protected Label labReadNum;
        protected Label labReadUser;
        protected Label labTime;
        protected Label labTitleInfo;
        private PublicFun publicFun_0 = new PublicFun();

        protected void ImgButExit_Click(object sender, ImageClickEventArgs e)
        {
            base.Response.Cookies["ExamUserCode"].Value = "";
            base.Response.Cookies["ExamUserName"].Value = "";
            base.Response.Cookies["ExamDeptName"].Value = "";
            base.Response.Cookies["ExamDeptID"].Value = "";
            base.Response.Cookies["ExamWorker"].Value = "";
            base.Response.Cookies["ExamUserSex"].Value = "";
            base.Response.Cookies["ExamUserLevel"].Value = "";
            base.Response.Cookies["ExamUserGWName"].Value = "";
            base.Response.Cookies["ExamUserGWLevel"].Value = "";
            string str = base.Request.Url.ToString();
            str = str.Substring(0, str.LastIndexOf('/') + 1);
            base.Response.Redirect(str + "FrmLogin.aspx");
        }

        private void method_0()
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlDataReader reader = new SqlCommand("select ReadUser,Flag,TitleInfo,ContentInfo,FileName,InputUser,InputTime,BrowNum from NewsInfo where ID=" + this.int_0, connection).ExecuteReader(CommandBehavior.CloseConnection);
            if (reader.Read())
            {
                this.labInputUser.Text = reader["InputUser"].ToString().Trim();
                this.labReadNum.Text = reader["BrowNum"].ToString().Trim();
                this.labTime.Text = reader["InputTime"].ToString().Trim();
                if (!(reader["ReadUser"].ToString().Trim() == ""))
                {
                    this.labReadUser.Text = reader["ReadUser"].ToString().Trim();
                    if (reader["ReadUser"].ToString().Trim().IndexOf("," + this.httpCookie_0.Value + ",") == -1)
                    {
                        this.labReadUser.Text = reader["ReadUser"].ToString().Trim() + this.httpCookie_0.Value + ",";
                    }
                }
                else
                {
                    this.labReadUser.Text = "," + this.httpCookie_0.Value + ",";
                }
                this.labTitleInfo.Text = reader["TitleInfo"].ToString();
                this.labNewsInfo.Text = reader["ContentInfo"].ToString();
            }
            reader.Close();
            connection.Close();
            connection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 == null) || (this.httpCookie_0.Value == ""))
            {
                base.Response.Write("<script language=javascript>window.location.href='FrmLogin.aspx';</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.int_0 = Convert.ToInt32(base.Request["ID"].ToString());
                if (!base.IsPostBack)
                {
                    this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                    this.method_0();
                    this.publicFun_0.ExecuteSql(string.Concat(new object[] { "update NewsInfo set BrowNum=BrowNum+1,ReadUser='", this.labReadUser.Text.Trim(), "' where ID=", this.int_0 }));
                }
            }
        }
    }
}

